package com.springboot.thymeleaf.springbootthymeleaf.filter;


import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.IOException;

/**
 * @Classname ${小柯}
 * @Description TODO
 * @Date 2019/9/29 15:38
 * @Created by Administrator
 */

@Slf4j
@Component
public class MyTestFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("1111111111111111111111111");
        log.info("filter 初始化");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("2222222222222222222222222");
        log.info("doFilter 请求处理");
        //TODO 进行业务逻辑

        //链路 直接传给下一个过滤器
        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy() {
        System.out.println("33333333333333333333333333");
        log.info("filter 销毁");
    }
}
